typedef struct TreeNode BTNode;
struct TreeNode* lowestCommonAncestor(struct TreeNode* root, struct TreeNode* p, struct TreeNode* q) {
    if (root == NULL || root == p || root == q)
    {
        return root;
    }
    BTNode* left = lowestCommonAncestor(root->left, p, q);
    BTNode* right = lowestCommonAncestor(root->right, p, q);
    if (left && right) {
        return root;
    }
    return left ? left : right;
}